﻿using System;
using System.Windows.Forms;

namespace Administracja
{
    public partial class ParentWindow : Form
    {
        public static ParentWindow ParentStatic;

        public ParentWindow()
        {
            InitializeComponent();

            ParentStatic = this;
            Text = "Administracja v. " + Application.ProductVersion;

            var z = new Glowne(0) { MdiParent = this };
            z.Show();
        }

        private void Parent_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!Program.Zamykam)
            {
                if (Wyjatki.Komunikat("Czy chcesz zakończyć pracę z programem?", "Zakończyć?", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                {
                    Baza.CloseConnection();
                    Program.Zamykam = true;
                }
                else
                {
                    e.Cancel = true;
                }
            }
            else
            {
                Baza.CloseConnection();
            }
        }

        private void osobyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var z = new Glowne(1) { MdiParent = this };
            z.Show();
        }

        private void zakupyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var z = new Glowne(2) { MdiParent = this };
            z.Show();
        }

        private void zestawieniaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new Zestawienia().ShowDialog();
        }

        private void inneObrotyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var z = new InneObroty { MdiParent = this };
            z.Show();
        }

        private void saldoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var z = new Salda { MdiParent = this };
            z.Show();
        }

        private void daneSprzedawcyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new Sprzedawca().ShowDialog();
        }

        private void składnikiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new OsobySkladniki().ShowDialog();
        }

        private void ZarzadzajLatamiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var z = new Zarzadzanie { MdiParent = this };
            z.Show();
        }

        private void podgladZawBazyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var z = new PodgladBazy { MdiParent = this };
            z.Show();
        }

        private void sprawdźAktualizacjeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new Aktualizacja().ShowDialog();
        }

        private void oProgramieToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new OProgramie().ShowDialog();
        }
    }
}
